import type { BasicTableColumn } from '@/components/table';
import TableFieldType from '@/components/table/src/types/field-type';
import type { FormSchema } from '@/components/form';
import FormFieldType from '@/components/form/src/types/field-type';

export const columns: BasicTableColumn[] = [
  {
    title: 'deptId',
    key: 'deptId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '部门名称',
    key: 'deptName',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '部门类别编码',
    key: 'deptCategory',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: 'parentId',
    key: 'parentId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '显示顺序',
    key: 'orderNum',
    align: 'center',
    width: 90,
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '负责人',
    key: 'leader',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '联系电话',
    key: 'phone',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '邮箱',
    key: 'email',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: 'delFlag',
    key: 'delFlag',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '祖级列表',
    key: 'ancestors',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '状态',
    key: 'status',
    fieldType: TableFieldType.BOOLEAN,
    width: 100,
    align: 'center',
    booleanOptions: {
      colorType: value => (value === '0' ? 'success' : 'error'),
    },
  },
];

export const formSchemas: FormSchema[] = [
  {
    field: 'deptId',
    label: '部门id',
    component: FormFieldType.INPUT,
    display: false,
  },
  {
    field: 'parentId',
    label: '上级部门',
    component: FormFieldType.TREE_SELECT,
    componentProps: {
      shareDataKey: 'departmentTreeData',
      defaultFirst: true,
      keyField: 'deptId',
      labelField: 'deptName',
    },
  },
  {
    field: 'deptName',
    label: '部门名称',
    component: FormFieldType.INPUT,
    rules: [{ required: true }],
  },
  {
    field: 'orderNum',
    component: FormFieldType.INPUT_NUMBER,
    label: '显示顺序',
    rules: [{ required: true }],
  },
  {
    field: 'deptCategory',
    label: '部门类别编码',
    component: FormFieldType.INPUT,
  },
  {
    field: 'leader',
    label: '负责人',
    component: FormFieldType.INPUT,
  },
  {
    field: 'phone',
    label: '联系电话',
    component: FormFieldType.INPUT,
  },
  {
    field: 'email',
    label: '邮箱',
    component: FormFieldType.INPUT,
  },
  {
    field: 'status',
    label: '菜单状态',
    component: FormFieldType.RADIO_GROUP,
    componentProps: {
      options: [
        {
          label: '正常',
          value: '0',
          type: 'success',
        },
        {
          label: '停用',
          value: '1',
          type: 'error',
        },
      ],
    },
    defaultValue: '0',
  },
];

export const searchSchemas: FormSchema[] = [
  // {
  //   field: 'parentId',
  //   label: '上级部门',
  //   component: FormFieldType.INPUT,
  // },
  {
    field: 'deptName',
    label: '部门名称',
    component: FormFieldType.INPUT,
  },
  {
    field: 'leader',
    label: '负责人',
    component: FormFieldType.INPUT,
  },
];
